package com.ivi.car.module.carstate.presenter;

import android.arch.lifecycle.Lifecycle;

import com.ivi.car.base.BasePresenter;
import com.ivi.car.bean.carstate.FaultDetial;
import com.ivi.car.bean.carstate.PressureDetial;
import com.ivi.car.module.carstate.model.FaultModel;
import com.ivi.car.module.carstate.model.IFaultDetialContract;
import com.trello.rxlifecycle2.LifecycleProvider;

import java.util.ArrayList;

/**
 * Copyright
 * author chengxp
 * date 2018/3/8
 * describe
 * history
 */

public class FaultPresenter extends BasePresenter<IFaultDetialContract.View> implements IFaultDetialContract.Presenter {

    private final FaultModel mFaultModel;

    public FaultPresenter(IFaultDetialContract.View view, LifecycleProvider<Lifecycle.Event> provider) {
        super(view, provider);
        mFaultModel = new FaultModel(provider);
    }

    @Override
    public void showPressureDetial() {
        PressureDetial detial = mFaultModel.getPressureDetial();
        if (null != detial) {
            mView.showPressureDetial(detial);
        }
    }

    @Override
    public void showFaultList() {
        ArrayList<FaultDetial> list = mFaultModel.getFaultList();
        if (!list.isEmpty()) {
            mView.showFaultList(list);
        }
    }
}
